package pro.shushi.pamirs.demo.api.model;

import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.demo.api.enumeration.ItemStatusEnum;
import pro.shushi.pamirs.demo.api.enumeration.ItemStockStatusEnum;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.common.CodeModel;
import pro.shushi.pamirs.meta.enmu.DateFormatEnum;
import pro.shushi.pamirs.meta.enmu.DateTypeEnum;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * code的生成规则可指定类型：pro.shushi.pamirs.meta.enmu.SequenceEnum
 */
@Model.model(DemoItem.MODEL_MODEL)
@Model(displayName = "测试商品", labelFields = "name")
@Model.Code(sequence = "SEQ", prefix = "IT", size = 8)
public class DemoItem extends CodeModel {

    private static final long serialVersionUID = -5104390780952631397L;

    public static final String MODEL_MODEL = "demo.DemoItem";

    @UxTableSearch.FieldWidget(@UxWidget())//支持搜索
    @Field.String
    @Field(displayName = "商品名称")
    private String name;

    @Field.Html
    @Field(displayName = "商品描述")
    private String description;

    @Field.Money(D=2)
    @Field(displayName = "商品价格")
    private BigDecimal itemPrice;

    @Field.Integer
    @Field(displayName = "商品库存")
    private Long inventoryQuantity;

    @Field.Date(type = DateTypeEnum.DATETIME, format = DateFormatEnum.DATETIME)
    @Field(displayName = "发布时间")
    private Date publishTime;

    @Field.Date(type = DateTypeEnum.TIME, format = DateFormatEnum.TIME)
    @Field(displayName = "发布时辰")
    private Date itemTime;

    @Field.Integer
    @Field(displayName = "类目ID")
    private Long categoryId;

    @Field.many2one
    @Field.Relation(relationFields = {"categoryId"}, referenceFields = {"id"})
    @Field(displayName = "商品类目")
    private DemoItemCategory category;

    @Field.String
    @Field.Related(related = {"category", "name"})
    @Field(displayName = "类目名称")
    private String categoryName;

    @Field.many2many(throughClass = DemoItemRelLabel.class, pageSize = Integer.MAX_VALUE,relationFields = {"itemId"}, referenceFields = {"labelId"})
    @Field.Relation(relationFields = {"id"}, referenceFields = {"id"})
    @Field(displayName = "商品标签")
    private List<DemoItemLabel> itemLabels;

    @Field.one2many
    @Field(displayName = "商品属性")
    @Field.Relation(relationFields = "id",referenceFields = "itemId")
    private List<DemoItemAttribute> itemAttributes;

    @Field.Enum
    @Field(displayName = "状态")
    private ItemStatusEnum status;

    @Field.Date(type = DateTypeEnum.YEAR, format = DateFormatEnum.YEAR)
    @Field(displayName = "年份")
    private Date year;

    @Field.Date(type = DateTypeEnum.DATE, format = DateFormatEnum.DATE)
    @Field(displayName = "入库日期")
    private Date inDate;

    @Field.Date(type = DateTypeEnum.TIME, format = DateFormatEnum.TIME)
    @Field(displayName = "时辰")
    private Date time;

    @Field.Enum
    @Field(displayName = "库存状态")
    private ItemStockStatusEnum stockStatus;

    @Field.Enum
    @Field(displayName = "历史库存状态", multi = true)
    private List<ItemStockStatusEnum> stockStatusList;

}
